﻿package mortal.game.view.guild.otherpanel
{
    import com.mui.controls.*;
    import extend.language.*;
    import flash.events.*;
    import mortal.component.window.*;
    import mortal.game.resource.*;
    import mortal.game.resource.info.item.*;
    import mortal.game.utils.*;
    import mortal.game.view.common.*;
    import mortal.game.view.common.item.*;
    import mortal.mvc.interfaces.*;

    public class SelectNumPanel extends SmallWindow
    {
        private var _item:BaseItem;
        private var _itemName:GTextFiled;
        private var _tip:GTextFiled;
        private var _numInput:GNumericStepper;
        private var _btnYes:GButton;
        private var _btnNo:GButton;
        private var _yesFun:Function;
        private var _noFun:Function;
        private static var _instance:SelectNumPanel;

        public function SelectNumPanel(param1:ILayer = null)
        {
            super(param1);
            setSize(245, 150);
            return;
        }// end function

        private function onBtnYesClick(event:MouseEvent) : void
        {
            if (this._yesFun != null)
            {
                this._yesFun.call(this, this._numInput.value);
            }
            this.hide();
            return;
        }// end function

        private function onBtnNoClick(event:MouseEvent) : void
        {
            if (this._noFun != null)
            {
                this._noFun.call();
            }
            this.hide();
            return;
        }// end function

        public function setData(param1:ItemData, param2:String = "", param3:String = "", param4:Function = null, param5:Function = null) : void
        {
            this._item.itemData = param1;
            this._item.setAmountLabel("");
            this._itemName.htmlText = ItemsUtil.getItemName(param1);
            this._numInput.minimum = 1;
            this._numInput.maximum = param1.itemAmount;
            this._numInput.value = param1.itemAmount;
            this._numInput.visible = param1.itemInfo.overlay > 1;
            title = param2;
            this._tip.htmlText = param3;
            this._yesFun = param4;
            this._noFun = param5;
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            this._item = UIFactory.getUICompoment(BaseItem, 25, 48, this);
            this._item.setItemStyle(ItemStyleConst.Small, ImagesConst.PackItemBg, 2, 3);
            this._itemName = UIFactory.textField("", 70, 48, 100, 22, this);
            this._tip = UIFactory.textField("" + Language.getString(71266), 70, 68, 100, 22, this);
            this._numInput = UIFactory.gNumericStepper(128, 66, 49, 20, this, 999, 1, "NumericStepper");
            this._btnYes = UIFactory.gButton("" + Language.getString(71267), 46, 110, 65, 22, this);
            this._btnNo = UIFactory.gButton("" + Language.getString(71268), 135, 110, 65, 22, this);
            this._btnYes.configEventListener(MouseEvent.CLICK, this.onBtnYesClick);
            this._btnNo.configEventListener(MouseEvent.CLICK, this.onBtnNoClick);
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            super.disposeImpl(param1);
            this._item.dispose(param1);
            this._itemName.dispose(param1);
            this._tip.dispose(param1);
            this._numInput.dispose(param1);
            this._btnYes.dispose(param1);
            this._btnNo.dispose(param1);
            this._item = null;
            this._itemName = null;
            this._tip = null;
            this._numInput = null;
            this._btnYes = null;
            this._btnNo = null;
            this._yesFun = null;
            this._noFun = null;
            return;
        }// end function

        public static function get instance() : SelectNumPanel
        {
            if (_instance == null)
            {
                _instance = new SelectNumPanel;
            }
            return _instance;
        }// end function

    }
}
